package org.ldx.lotterysystem.service.mq;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;

import static org.ldx.lotterysystem.common.config.DirectRabbitConfig.*;

/**
 * @author 帘低晓露湿
 * @date 2025/11/18 14:29
 */
@Slf4j
@Component
@RabbitListener(queues = DLX_QUEUE_NAME) //监听队列：DLX_QUEUE_NAME
public class DlxReceiver {
    @Resource
    RabbitTemplate rabbitTemplate;

    /**
     * 处理死信队列里的消息
     * @param map
     */
    @RabbitHandler
    public void process( Map<String,String> map){
        log.info("开始处理异常消息");
    //发消息 :交换机,绑定的key(队列)，消息体
        rabbitTemplate.convertAndSend(EXCHANGE_NAME,ROUTING,map);}
}
